<!--#include file="conn.asp"-->
<!--#include file="chkuser.asp"-->
<%
call adminRight(1)

ID=request("ID")

if request("action")="Del" then
	If ID="" Then Alert("没有选择数据"):GoBack():response.End()
	if instr(ID,",")<=0 then
		call delClassList(ID)
	else
		arrID=split(ID,",")
		for arrID_i=0 to ubound(arrID)
			call delClassList(arrID(arrID_i))
		next
	end if
	Go("?showMsgStr=<br><b>类别已删除成功！</b>|parent|3000|500||")
end if

sub delClassList(ID) '递归方法删除类及子类
	dim rsc
	set rsc=server.CreateObject("adodb.recordset")
	sqlc="select * from ProductClass where ParentClassID="&ID
	rsc.open sqlc,conn,1,1
	do while not rsc.eof
		call delClassList(rsc("ID"))
	rsc.movenext
	loop
	rsc.close
	set rsc=nothing
	dim rsDel
	set rsDel=server.CreateObject("adodb.recordset")
	sql="select * from ProductClass where ID="&ID
	rsDel.open sql,conn,1,3
	if not rsDel.eof then
		if rsDel("pic")<>"" then call DelFile("../"&rsDel("pic"))
		rsDel.delete
		rsDel.update
	end if
	rsDel.close
	set rsDel=nothing
end sub
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>类别管理</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript">
function selcheck(id) {
   var e =document.getElementById(id);
   var objs = e.getElementsByTagName("input");
   if (e.checked){
      e.checked = false;
      for(var i=0; i<objs.length; i++) {
         if(objs[i].type.toLowerCase() == "checkbox" )
         objs[i].checked = false;
      }
   }   else   {
      e.checked = true;
      for(var i=0; i<objs.length; i++) {
         if(objs[i].type.toLowerCase() == "checkbox" )
         objs[i].checked = true;
      }
   }
}
</script>
</head>
<body>
    <div id="frame_Toolbar" class="toolbarBg"> 
		<a href="javascript:self.history.back();" class="icoBtn_ct"><span class="btnIco btnBack"></span>返回</a> 
		<a href="javascript:self.location.reload();" class="icoBtn_ct"><span class="btnIco btnReload"></span>刷新</a> 
		<span class="split ftSplit" ></span>
	    <div id="guide">
			点击<span class="light_orange"> 类别名称 </span>进行编辑&nbsp;&nbsp;&nbsp;&nbsp;
			<a href="admin_productclass_add.asp">添加新类别</a>
		</div>
		<%
			   Set rs = Server.CreateObject("ADODB.Recordset")
			   sql="select * from ProductClass order by px desc,id desc"
			   rs.open sql,conn,1,1
	    %>
	    <div class="pageInfo right light_gray">[当前共有<span id="Label_total_top" class="light_bOrange"><%=rs.recordcount%></span>条记录]</div>
		<%
		      rs.close
			  set rs=nothing
		%>
    </div>
	<form method="POST" id=form2 name="form2" action="">
	<div id="MainContent">
     <table class="cTable table tCenter">
	    <tr class="cTitle toolbarBg" id="Title">
		    <td width="6%"><span class="checkbox"><input type="checkbox" name="chkall" onClick="selcheck('MainContent')" /></span></td>
		    <td><span class="split ctSplit"></span><div>类别名称</div></td>
		    <td width="12%"><span class="split ctSplit"></span><div>排序</div></td>
			<td width="20%"><span class="split ctSplit"></span><div>编辑</div></td>
	    </tr>
	    <%
			   Set rs = Server.CreateObject("ADODB.Recordset")
			   sql="select * from ProductClass where ParentClassID = 0 order by px desc,id desc"
			   rs.open sql,conn,1,1
				 
			   for i=1 to rs.recordcount
			   if rs.eof then
			   exit for
			   end if
			   str=rs("ClassName")
		 %>
		<tr class="trDataList" onMouseOver="this.className='trDataListHover'" onMouseOut="this.className='trDataList'">
			<td><input type="checkbox" name="ID" value="<%=rs("ID")%>" /></td>
			<td align="left"><a href="Admin_ProductClass_Edit.asp?ID=<%=rs("ID")%>" title="<%=str%>"><b><%=gotTopic(str,33)%></b></a></td>
			<td><iframe name="px" style="width:95px; height:25px" scrolling="no" frameborder="0" align="middle" src="Admin_ProductClass_px.asp?id=<%=rs("id")%>"></iframe></td>
			<td><%if ProductClassSD_con>=2 then%><a href="Admin_ProductClass_Add.asp?ID=<%=rs("ID")%>">添加子栏目</a>/<%end if%><a href="Admin_ProductClass_Edit.asp?ID=<%=rs("ID")%>">编辑</a>/<a href="?ID=<%=rs("ID")%>&action=Del" onClick="return confirm('确定删除？')">删除</a></td>
		</tr>
		<%
			   Set rs1 = Server.CreateObject("ADODB.Recordset")
			   sql1="select * from ProductClass where ParentClassID = "& rs("ID") &" order by px desc,id desc"
			   rs1.open sql1,conn,1,1
			   
			   for j=1 to rs1.recordcount
			   if rs1.eof then
			   exit for
			   end if
			   str1=rs1("ClassName")
		 %>
		<tr class="trDataList" onMouseOver="this.className='trDataListHover'" onMouseOut="this.className='trDataList'">
			<td><input type="checkbox" name="ID" value="<%=rs1("ID")%>" /></td>
			<td align="left" style="padding-left:15px">+ <a href="Admin_ProductClass_Edit.asp?ID=<%=rs1("ID")%>" title="<%=str1%>"><%=gotTopic(str1,33)%></a></td>
			<td><iframe name="px" style="width:95px; height:25px" scrolling="no" frameborder="0" align="middle" src="Admin_ProductClass_px.asp?id=<%=rs1("id")%>"></iframe></td>
			<td><%if ProductClassSD_con>=3 then%><a href="Admin_ProductClass_Add.asp?ID=<%=rs1("ID")%>">添加子栏目</a>/<%end if%><a href="Admin_ProductClass_Edit.asp?ID=<%=rs1("ID")%>">编辑</a>/<a href="?ID=<%=rs1("ID")%>&action=Del" onClick="return confirm('确定删除？')">删除</a></td>
		</tr>
		<%
			   Set rs2 = Server.CreateObject("ADODB.Recordset")
			   sql2="select * from ProductClass where ParentClassID = "& rs1("ID") &" order by px desc,id desc"
			   rs2.open sql2,conn,1,1
			   
			   for k=1 to rs2.recordcount
			   if rs2.eof then
			   exit for
			   end if
			   str2=rs2("ClassName")
		 %>
		<tr class="trDataList" onMouseOver="this.className='trDataListHover'" onMouseOut="this.className='trDataList'">
			<td><input type="checkbox" name="ID" value="<%=rs2("ID")%>" /></td>
			<td align="left" style="padding-left:30px">- <a href="Admin_ProductClass_Edit.asp?ID=<%=rs2("ID")%>" title="<%=str2%>"><%=gotTopic(str2,33)%></a></td>
			<td><iframe name="px" style="width:95px; height:25px" scrolling="no" frameborder="0" align="middle" src="Admin_ProductClass_px.asp?id=<%=rs2("id")%>"></iframe></td>
			<td><%if ProductClassSD_con>=4 then%><a href="Admin_ProductClass_Add.asp?ID=<%=rs2("ID")%>">添加子栏目</a>/<%end if%><a href="Admin_ProductClass_Edit.asp?ID=<%=rs2("ID")%>">编辑</a>/<a href="?ID=<%=rs2("ID")%>&action=Del" onClick="return confirm('确定删除？')">删除</a></td>
		</tr>
		<%
			   Set rs3 = Server.CreateObject("ADODB.Recordset")
			   sql3="select * from ProductClass where ParentClassID = "& rs2("ID") &" order by px desc,id desc"
			   rs3.open sql3,conn,1,1
			   
			   for w=1 to rs3.recordcount
			   if rs3.eof then
			   exit for
			   end if
			   str3=rs3("ClassName")
		 %>
		<tr class="trDataList" onMouseOver="this.className='trDataListHover'" onMouseOut="this.className='trDataList'">
		  <td><input type="checkbox" name="ID" value="<%=rs3("ID")%>" /></td>
		  <td align="left" style="padding-left:45px">· <a href="Admin_ProductClass_Edit.asp?ID=<%=rs3("ID")%>" title="<%=str3%>"><%=gotTopic(str3,33)%></a></td>
		  <td><iframe name="px" style="width:95px; height:25px" scrolling="no" frameborder="0" align="middle" src="Admin_ProductClass_px.asp?id=<%=rs3("id")%>"></iframe></td>
		  <td align="center"><%if ProductClassSD_con>=5 then%><a href="Admin_ProductClass_Add.asp?ID=<%=rs3("ID")%>">添加子栏目</a>/<%end if%><a href="Admin_ProductClass_Edit.asp?ID=<%=rs3("ID")%>">编辑</a>/<a href="?ID=<%=rs3("ID")%>&action=Del" onClick="return confirm('确定删除？')">删除</a></td>
	  </tr>
		<%
			   Set rs4 = Server.CreateObject("ADODB.Recordset")
			   sql4="select * from ProductClass where ParentClassID = "& rs3("ID") &" order by px desc,id desc"
			   rs4.open sql4,conn,1,1
			   
			   for l=1 to rs4.recordcount
			   if rs4.eof then
			   exit for
			   end if
			   str4=rs4("ClassName")
		 %>
		<tr class="trDataList" onMouseOver="this.className='trDataListHover'" onMouseOut="this.className='trDataList'">
		  <td><input type="checkbox" name="ID" value="<%=rs4("ID")%>" /></td>
		  <td align="left" style="padding-left:60px">› <a href="Admin_ProductClass_Edit.asp?ID=<%=rs4("ID")%>" title="<%=str4%>"><%=gotTopic(str4,33)%></a></td>
		  <td><iframe name="px" style="width:95px; height:25px" scrolling="no" frameborder="0" align="middle" src="Admin_ProductClass_px.asp?id=<%=rs4("id")%>"></iframe></td>
		  <td><a href="Admin_ProductClass_Edit.asp?ID=<%=rs4("ID")%>">编辑</a>/<a href="?ID=<%=rs4("ID")%>&action=Del" onClick="return confirm('确定删除？')">删除</a></td>
	  </tr>
		<%
			rs4.movenext
			next
			rs4.close
			set rs4=nothing
        %>
		<%
			rs3.movenext
			next
			rs3.close
			set rs3=nothing
        %>
		<%
			rs2.movenext
			next
			rs2.close
			set rs2=nothing
        %>
		<%
			rs1.movenext
			next
			rs1.close
			set rs1=nothing
        %>
		<%
			rs.movenext
			next
			rs.close
			Set rs=nothing
        %>
	</table> 
    </div>
    <div id="cEndToolbar" class="toolbarBg">
		<div class="pageSelect"><span class="iptSl"><input type="checkbox" name="chkall" onClick="selcheck('MainContent')" /></span><a href="javascript:selcheck('MainContent');"><span class="btnTxt">选择</span></a></div>
	    <span class="split cpSplit" ></span>
	    <div class="pageBtnDo">
	        <div class="icoBtn_do"><input type="image" name="Delete_Button" id="Delete_Button" class="btnIco btnDel" src="images/Empty.gif" onClick="document.form2.action='?action=Del';return confirm('确定要删除吗?');" style="border-width:0px;" /></div>
	    </div>
    </div>
	</form>
</body>
</html>